function phi = phi2(spectrum,m,n,x,y)
LatticeSize = spectrum.LatticeSize;
XYmax = spectrum.XYmax;
if((m==0||2*m==LatticeSize)&&(n==0||2*n==LatticeSize))
    coeff = 1.0/XYmax;
elseif(m~=0 && 2*m~=LatticeSize && n~=0 && 2*n~=LatticeSize)
    coeff = 2.0/XYmax;
else
    coeff = sqrt(2)/XYmax;
end
phi = coeff*cos(2*m*pi*x/LatticeSize)*cos(2*n*pi*y/LatticeSize);
